# -*- coding: utf-8 -*-

import smtplib
from email.mime.text import MIMEText

# mailto_list = ["844063569@qq.com"]

mail_host = "smtp.126.com"
mail_user = "googlehitbaidu"
mail_pass = "shikaiwenxx"
mail_postfix = "126.com"

def send_mail(to_list,sub,content):

    me = "hello"+"<"+mail_user+"@"+mail_postfix+">"
    msg = MIMEText(content, _subtype='plain', _charset='utf-8')
    msg['Subject'] = sub
    msg['From'] = me
    msg['To'] = ";".join(to_list)
    try:
        server = smtplib.SMTP()
        server.connect(mail_host)
        server.login(mail_user, mail_pass)
        server.sendmail(me, to_list, msg.as_string())
        server.close()
        return True
    except Exception, e:
        print str(e)
        return False